## 
#
# Adds your Service Account to the Administrator of the machine
#
##



$split = $env:serviceacct.Split("\")
$domain = $split[0]
$user = $split[1]


function AddDomainUser(){
trap [Exception]{
Write-Host "$env:serviceacct is already a member of the Administrators Group on this Machine."
continue
}
$adObject = ([ADSI]"WinNT://localhost/Administrators,group").Add("WinNT://$domain/$user")  
}

Write-Host -ForegroundColor Yellow "Security: Adding Service Account - $env:ServiceAcct to Local Administrators Group."
AddDomainUser
Write-Host -ForegroundColor Yellow "Security: Adding Service Account - $env:ServiceAcct to Local Administrators Group. COMPLETED"

